<template>
	<view class="b-list-box">
		<view class="b-list-header" @click="click">
			<view class="b-list-header__title">
				<text>{{title}}</text>
				<text class="font-color-grey" v-if="label">({{label}})</text>
			</view>
			<view class="b-list-header__desc font-color-grey">
				<text class="u-p-r-10">{{value}}</text>
				<u-icon :name="showIcon"></u-icon>
			</view>
		</view>
		<view class="b-list-item-box" v-show="isShow">
			<slot />
		</view>
	</view>
</template>

<script>
	export default {
		name: "b-list-group",
		props: {
			// 分组标题
			title: {
				type: String,
				default: ''
			},
			value: {
				type: Number | String,
				default: ''
			},
			label: {
				type: Number | String,
				default: ''
			}
		},
		data() {
			return {
				isShow: true
			};
		},
		computed:{
			showIcon: function(){
				return this.isShow ? "arrow-down" : "arrow-right";
			}
		},
		methods: {
			click() {
				this.isShow = !this.isShow
			}
		}
	}
</script>

<style lang="scss" scoped>
	.b-list-box {
		display: flex;
		flex-direction: column;
		margin: 20rpx;
		background-color: #FFF;
		border-radius: 10px;

		.b-list-header {
			padding: 30rpx 20rpx;
			width: 100%;
			display: flex;
			font-size: 32rpx;
			justify-content: space-between;
		}
	}

	.font-color-grey {
		color: $uni-text-color-grey;
	}
</style>
